﻿// Fill out your copyright notice in the Description page of Project Settings.


#include "Actor/CreateBossPoint.h"

#include "GameMode/CombatGameMode.h"
#include "Helper/DebugHelper.h"
#include "Kismet/GameplayStatics.h"


// Sets default values
ACreateBossPoint::ACreateBossPoint()
{
	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
}

// Called when the game starts or when spawned
void ACreateBossPoint::BeginPlay()
{
	Super::BeginPlay();
	ACombatGameMode* GameMode = Cast<ACombatGameMode>(UGameplayStatics::GetGameMode(GetWorld()));
	GameMode->CreateBossPoint = this;
}

// Called every frame
void ACreateBossPoint::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
}

void ACreateBossPoint::CreateBoss()
{
	if (BossCharacterClass)
	{
		ACombatGameMode* GameMode = Cast<ACombatGameMode>(UGameplayStatics::GetGameMode(GetWorld()));
		ABossCharacter* BossCharacter = GetWorld()->SpawnActor<ABossCharacter>(BossCharacterClass, this->GetTransform());
		// 把boss放入到mainUi
		GameMode->MainUI->Boss = BossCharacter;
		GameMode->MainUI->BossHealthBarPanel->SetVisibility(ESlateVisibility::Visible);
	}
}
